<?php

namespace Admin\Service;
class PageService extends CommonService{
    
    /**
     * 添加单页数据
     * @param type $data
     * @return type
     */
    public function add($data) {
        $Page = $this->getD();
        if(false === ($page_content = $Page->create($data))){
            return $this->errorResultReturn($Page->getError());
        }
        
        if(false === $Page->add($page_content)){
            return $this->errorResultReturn("系统繁忙！");
        }
        return $this->resultReturn(TRUE);
    }
    
    /**
     * 修改单页
     * @param type $data
     * @return type
     */
    public function update($data) {
        $Page = $this->getD();
        if(false === ($page_content = $Page->create($data))){
            return $this->errorResultReturn($Page->getError());
        }
        if(false === $Page->save($page_content)){
            return $this->errorResultReturn("系统繁忙！");
        }
        return $this->resultReturn(TRUE);
    }
    
    /**
     * 删除单页
     * @param type $id
     * @return type
     */
    public function delete($id) {
        return $this->getM()->delete($id);
    }
    /**
     * 根据ID获取单页详情
     * @param type $id
     * @return type
     */
    public function getById($id) {
        return $this->getM()->getById($id);
    }
    
    protected function getModelName() {
        return "Page";
    }

}
